package cn.maincode.springdate.Controller;

import cn.maincode.springdate.JpaService.JpaUserService;
import cn.maincode.springdate.Pojo.Entity.JpaUser;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private JpaUserService jpaUserService;
    @RequestMapping("/add")
    public JpaUser addUser(JpaUser jpaUser){
        return jpaUserService.insert(jpaUser);
    }
    @RequestMapping("/delete/{id}")
    public void deleteUser(@PathVariable("id") long id){
        jpaUserService.delete(id);
    }
    @RequestMapping("/findAll")
    public List<JpaUser> findUsers(){
        return jpaUserService.findAll();
    }
    @RequestMapping("/findOne/{id}")
    public JpaUser findById(@PathVariable("id") long id){
        return jpaUserService.findById(id);
    }
    @RequestMapping("/hello")
    public String hello(){
        return "hello springs";
    }
}
